package common.exception;

/**
 * Data Access Exception, exceptions include such as:
 * Database operation exceptions or third services exceptions, etc.
 * 
 * @author bxiao
 *
 */
public class DataAccessException extends RuntimeException
{
	private static final long serialVersionUID = -3718692223359206815L;
	private ErrorCode code;
	
	public DataAccessException()
	{
		super();
	}
	
	public DataAccessException(Throwable cause)
	{
		super(cause);
	}
	
	public DataAccessException(String message, Throwable cause)
	{
		super(message, cause);
	}
	
	public DataAccessException(String message)
	{
		super(message);
	}
	
	public DataAccessException(String message, ErrorCode code)
	{
		super(message);
		this.code = code;
	}
	
	public DataAccessException(String message, ErrorCode code, Throwable cause)
	{
		super(message, cause);
		this.code = code;
	}

	public ErrorCode getCode() {
		return code;
	}

	public void setCode(ErrorCode code) {
		this.code = code;
	}

	public enum ErrorCode
	{
		DB("database"),
		ServerSite("third server site service");
		
		private String code;
		private ErrorCode(String code)
		{
			this.code = code;
		}
		@Override
		public String toString()
		{
			return code;
		}
	}
}

